<?php
include_once '../library/config.php';
include_once '../model/stafflist.php';
include_once '../model/userlist.php';
StaffList::IsLogin();
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>后台管理系统</title>
        <link href="/css/reset.css" rel="stylesheet" type="text/css" />
        <link href="/css/layout.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <?php
        $req=new HttpRequestHelper();
        $req->request();
        $entity=new UserList();
        if($req['oldpwd'])
        {
            $msg='密码已修改';
            if($req['pwd']==$req['repwd'])
            {
                $entity->keyvalue('pwd',md5($req['pwd']));
                if($entity->update()->where('myid=? and pwd=?',array($_COOKIE['myid'],md5($req['oldpwd'])))->submit()===0)
                {
                    $msg='原始密码错误';
                }
            }else
            {
                $msg="两次输入的密码不相等！";
            }
            ?>
            <script type="text/javascript">
                alert('<?php echo $msg;?>');
            </script>
            <?php
        }
        ?>
        <form method="post" class="mainwrap">
            <div class="mainwrapassist notoolbar nostatusbar">
                <table class="cellbor">
                    <tbody>
                        <tr>
                            <td class="w80 tr">原密码：</td>
                            <td class="w200"><input type="password" name="oldpwd"/></td>
                        </tr>
                        <tr>
                            <td class="tr">新密码：</td>
                            <td><input type="password" name="pwd"/></td>
                        </tr>
                        <tr>
                            <td class="tr">重复密码：</td>
                            <td><input type="password" name="repwd"/></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td><button type="submit">修改</button></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <?php include_once '../inc/js.html';?>
</body>
</html>